package com.sanji.sjmallapp;

import android.app.Application;
import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.sanji.sjmallmodule.goods.SearchTypeBean;
import com.sanji.sjmallutils.SDCardUtil;
import com.sanji.sjmallutils.SharePreferenceUtil;
import com.yolanda.nohttp.Logger;
import com.yolanda.nohttp.NoHttp;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.jpush.android.api.JPushInterface;

/**
 * Created by zsf on 16-12-8.
 */

public class MallApplication extends Application {
    //fragment、activity都可以拿到application
    public static MallApplication application;
    public static SharePreferenceUtil myShare = null;
    private List<SearchTypeBean> phoneList;//智能手机列表
    private List<SearchTypeBean> tableList;//平板列表
    private List<SearchTypeBean> partList;//配件类型列表
    private List<SearchTypeBean> smartLifeList;//智能生活列表
    private List<SearchTypeBean> smartStoreList;//移动便利店列表
    private List<SearchTypeBean> allNoPhoneList;//非配件以外的手机配品牌列表
    private List<SearchTypeBean> partBrandList;//配件品牌列表

    private Map<Integer,Boolean> refreshMap = null;
    private Map<Integer,Boolean> shellrefreshMap = null;

    @Override
    public void onCreate() {
        application = this;
        super.onCreate();
        initNoHttp();

        //JPush
        JPushInterface.setDebugMode(true);
        JPushInterface.init(this);

        //创建文件夹
        SDCardUtil.createAllFile(getApplicationContext());
        myShare = new SharePreferenceUtil(getApplicationContext());
        partList = new ArrayList<>();
        allNoPhoneList = new ArrayList<>();
        partBrandList = new ArrayList<>();

        refreshMap = new HashMap<>();
        for(int i=0;i<4;i++){
            refreshMap.put(i,false);
        }

        shellrefreshMap = new HashMap<>();
        for (int i=0;i<5;i++){
            shellrefreshMap.put(i,false);
        }
    }

    public static MallApplication getApplication() {
        return application;
    }

    private void initNoHttp() {
        NoHttp.initialize(this, new NoHttp.Config().setConnectTimeout(30 * 1000).setReadTimeout(30 * 1000));
        //发布发版时 关闭
        Logger.setDebug(true);
        Logger.setTag("NoHttpTag");
    }

    /**
     * 智能机列表
     */
    public void setPhoneList(List<SearchTypeBean> phoneListData) {
        this.phoneList = phoneListData;
    }

    /**
     * 平板列表
     */
    public void setTableList(List<SearchTypeBean> tableListData) {
        this.tableList = tableListData;
    }

    /**
     * 配件类型列表
     */
    public void setPartList(List<SearchTypeBean> partListData) {
        this.partList = partListData;
    }

    /**
     * 智能生活列表
     */
    public void setLifeList(List<SearchTypeBean> smartLifeData) {
        this.smartLifeList = smartLifeData;
    }

    /**
     * 移动便利店列表
     */
    public void setSmartStoreList(List<SearchTypeBean> smartStoreData) {
        this.smartStoreList = smartStoreData;
    }

    /**
     * 除了配件以外的手机品牌列表
     */
    public void setAllNoParetList(List<SearchTypeBean> noParteData) {
        this.allNoPhoneList = noParteData;
    }

    /**
     * 配件的品牌列表
     */
    public void setPartBrandList(List<SearchTypeBean> partBrandList) {
        this.partBrandList = partBrandList;
    }

    /**
     * @return 返回手机列表
     */
    public List<SearchTypeBean> getPhoneList() {
        return phoneList;
    }

    public List<SearchTypeBean> getTableList() {
        return tableList;
    }

    public List<SearchTypeBean> getPartList() {
        return partList;
    }

    public List<SearchTypeBean> getSmartLifeList() {
        return smartLifeList;
    }

    public List<SearchTypeBean> getSmartStoreList() {
        return smartStoreList;
    }

    public List<SearchTypeBean> getAllNoPhoneList() {
        return allNoPhoneList;
    }

    public List<SearchTypeBean> getPartBrandList() {
        return partBrandList;
    }

    public Map<Integer, Boolean> getRefreshMap() {
        return refreshMap;
    }

    public Map<Integer, Boolean> getShellRefreshMap() {
        return shellrefreshMap;
    }

}
